home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_400 / 405_01 / MyCompiler.cc < prev    next >
C/C++ Source or Header  |  1993-06-12  |  1KB  |  53 lines

  1. static char SccsId[]="%Z% %M% %Y% %Q% %I% %E% %U% (%F%)";
  2. //
  3. // Nom du Fichier :     |>nom_fichier<|
  4. // Titre :         |>Titre<|
  5. // Auteur:        |>auteur<|        
  6. // Date de creation :    |>dateCreation<|
  7. //
  8. // Description :
  9. //    Document de reference : |>doc<|
  10. //    Objet : |>objet<|
  11. //
  12. //
  13. // 
  14. // historique :
  15. // |>date<|    |>auteur<|    |>objet<|
  16. //
  17. #include "MyScanner.h"
  18. #include "MyParser.h"
  19.  
  20. class MyCompiler : public MyParser
  21. {private:
  22.  MyScanner theScanner;
  23.  public:
  24.  virtual int yylex();
  25.  virtual void yyerror(char *m);
  26.  MyCompiler() 
  27.   {};
  28. };
  29.  
  30. int MyCompiler::yylex()
  31. {
  32.  yylloc.first_line=theScanner.theLine;
  33.  yylloc.first_column=theScanner.theColumn;
  34.  int token=theScanner.yylex(&yylval,&yylloc);
  35.  yylloc.last_line=theScanner.theLine;
  36.  yylloc.last_column=theScanner.theColumn;
  37.  yylloc.text=(char *)theScanner.yytext;
  38.  return token;
  39. }
  40.  
  41. void MyCompiler::yyerror(char *m)
  42. { fprintf(stderr,"%d: %s at token '%s'\n",yylloc.first_line, m,yylloc.text);
  43. }
  44.  
  45. int main(int argc,char **argv)
  46. {
  47.  MyCompiler aCompiler;
  48.  int result=aCompiler.yyparse();
  49.  printf("Resultat Parsing=%s\n",result?"Erreur":"OK");
  50.  return 0;
  51. };
  52.  
  53.